﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using POSGui.Classes.BusinessLogic;
using POSGui.Classes;
using POSGui;

public partial class Account_Login : System.Web.UI.Page
{
    protected global::System.Web.UI.WebControls.Login LoginUser;

    protected void Page_Load(object sender, EventArgs e)
    {        
    }

    private bool login(string username, string password, string branch)
    {
        WebServiceAgent serviceAgent = ClientManager.GetInstance().LogIn(username, password, branch);
        if (serviceAgent == null)
        {
            LoginUser.FailureText = Constants.USER_ERROR;
            return false;
        }
        else
        {
            Session.Add(Constants.USER_WEB_SERVICE_CONN, serviceAgent);
            return true;
        }
    }

    protected void LoginButton_Click(object sender, AuthenticateEventArgs e)
    {
        e.Authenticated = login(LoginUser.UserName, LoginUser.Password, Constants.COMPANY_NAME);
    }
}
